package com.health.validation;

import com.health.dto.RegisterRequest;
import org.springframework.stereotype.Component;

@Component
public class UserValidator {
    
    public void validateRegisterRequest(RegisterRequest request) {
        if (request.getUsername() == null || request.getUsername().length() < 3) {
            throw new RuntimeException("用户名长度不能小于3个字符");
        }
        
        if (request.getPassword() == null || request.getPassword().length() < 6) {
            throw new RuntimeException("密码长度不能小于6个字符");
        }
        
        if (request.getEmail() == null || !request.getEmail().matches("^[A-Za-z0-9+_.-]+@(.+)$")) {
            throw new RuntimeException("邮箱格式不正确");
        }
    }
} 